#!/bin/bash

set -e

if [[ -n "${RASTER_VISION_DEBUG}" ]]; then
    set -x
fi

function usage() {
    echo -n \
         "Usage: $(basename "$0") [--cpu|--gpu|--jupyter]
Build docker images for model training.
If the type is not specified, it will build both cpu and gpu docker images.
"
}

if [ "${BASH_SOURCE[0]}" = "${0}" ]
then
    if [ "${1:-}" = "--help" ]
    then
        usage
        exit
    fi

    docker build -t raster-vision-base -f src/Dockerfile-base src

    if [ $# -eq 0 -o "${1:-}" = "--cpu" ]
    then
        docker build -t raster-vision-cpu -f src/Dockerfile-cpu src
    fi
    if [ $# -eq 0 -o "${1:-}" = "--gpu" ]
    then
        docker build -t raster-vision-gpu -f src/Dockerfile-gpu src
    fi
    if [ $# -eq 0 -o "${1:-}" = "--jupyter" ]
    then
        docker build -t raster-vision-jupyter -f src/Dockerfile-jupyter src
    fi
fi
